using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace EuropeEngulfed.NET
{
    partial class ForcePoolAdditionsDialog : Form
    {
        private List<GameState.ForcePoolAdjustment> listOfAdjustments;
        public ForcePoolAdditionsDialog(GameTurn.GameDate gameDate, List<GameState.ForcePoolAdjustment> listOfAdjustments)
        {
            InitializeComponent();
            this.listOfAdjustments = listOfAdjustments;
            this.ForcePoolAdditionsDialogTitleLabel.Text += GameTurn.GameDateToString(gameDate);

            this.forcePoolAjustmentsListView.View = View.Tile;
            this.forcePoolAjustmentsListView.TileSize = new Size(PlayingPieceGraphics.GetSASize().Width * 2, PlayingPieceGraphics.GetSASize().Height * 2);

            foreach (GameState.ForcePoolAdjustment forcePoolAdjustment in listOfAdjustments)
            {
                if(forcePoolAdjustment.forcePoolAjustmentType == GameState.ForcePoolAjustmentType.newBlockInForcePool)
                    this.forcePoolAjustmentsListView.Items.Add(forcePoolAdjustment.blockToAdd.GetDescription());
                else if(forcePoolAdjustment.forcePoolAjustmentType == GameState.ForcePoolAjustmentType.newSpecialActionInForcePool)
                    this.forcePoolAjustmentsListView.Items.Add(Enum.GetName(forcePoolAdjustment.country.GetType(), forcePoolAdjustment.country) + " Special Action");
                else if(forcePoolAdjustment.forcePoolAjustmentType == GameState.ForcePoolAjustmentType.specialActionRemoval)
                    this.forcePoolAjustmentsListView.Items.Add(Enum.GetName(forcePoolAdjustment.country.GetType(), forcePoolAdjustment.country) + " Special Action Removed");
            }

        }

        private void OkButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void forcePoolAjustmentslListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
            if(listOfAdjustments[e.ItemIndex].forcePoolAjustmentType == GameState.ForcePoolAjustmentType.newBlockInForcePool)
                PlayingPieceGraphics.PaintPlayingPiece(e.Graphics, listOfAdjustments[e.ItemIndex].blockToAdd, new Point(e.Bounds.Left + (e.Bounds.Width / 2), e.Bounds.Top + (e.Bounds.Height / 2)));
            else if(listOfAdjustments[e.ItemIndex].forcePoolAjustmentType == GameState.ForcePoolAjustmentType.newSpecialActionInForcePool || listOfAdjustments[e.ItemIndex].forcePoolAjustmentType == GameState.ForcePoolAjustmentType.specialActionRemoval)
            {
                PlayingPieceGraphics.PaintSpecialActions(e.Graphics, listOfAdjustments[e.ItemIndex].country, new Point(e.Bounds.Left + (e.Bounds.Width / 2), e.Bounds.Top + (e.Bounds.Height / 2)));
                if(listOfAdjustments[e.ItemIndex].forcePoolAjustmentType == GameState.ForcePoolAjustmentType.specialActionRemoval)
                {
                    e.Graphics.DrawLine(new Pen(Brushes.Red, 4), new Point(e.Bounds.Left, e.Bounds.Top), new Point(e.Bounds.Right, e.Bounds.Bottom));
                    e.Graphics.DrawLine(new Pen(Brushes.Red, 4), new Point(e.Bounds.Right, e.Bounds.Top), new Point(e.Bounds.Left, e.Bounds.Bottom));
                }
            }
        }
    }
}